1. Technology Field
The invention relates to a data management method and particularly to a management method for data written in a physical block of a rewritable non-volatile memory module and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Digital cameras, cells phones, and digital music players have undergone rapid growth in recent years. Thus, consumer demand for storage media has also rapidly increased. Rewritable non-volatile memory is one of the most adaptable memories for battery-powered portable products such as laptop computers due to its characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure, and high read and write speed. A solid-state drive (SSD) is a storage apparatus adopting flash memory as storage medium. Therefore, the flash memory industry has become a very important part of the electronic industry in recent years.
A memory sub-module of a flash memory module has a plurality of physical units. Each physical unit is formed from one or more physical blocks, and each physical block has a plurality of physical pages, wherein data must be written into a physical block according to the sequence of the physical pages in the physical block. Additionally, a physical page with data has to be erased before data is written in again. In particular, a smallest unit for erasing data is one physical block, and a smallest unit for programming (also referred to writing) data is one physical page. Therefore, in the management of the flash memory module, the physical units are grouped into a data area and a free area.
The physical units of the data area have used for storing data written by the host system. To be specific, a memory management circuit converts the logical access addresses accessed by the host system into corresponding logical pages of logical units, and maps the logical pages of the logical units to the physical pages of the physical units of the data area. Namely, in the management of the flash memory module, the physical units of the data area are used physical units (i.e. physical units storing data written by the host system). For example, the memory management circuit may use a logical unit-physical unit mapping table to record a mapping relationship between the logical units and the physical units of the data area, wherein the logical pages of the logical units are sequentially corresponding to the mapped physical pages of the physical units.
The physical units of the free area are used for substituting the physical units of the data area. Specifically, as described above, physical blocks written data must be erased before they are used for writing data again. Thus, the physical units of the free area are used to write update data to substitute the physical units that map the logical units. Hence, the physical units in the free area are either blank or available units (i.e., no data is recorded in these units or data recorded in these units is marked as useless data).
In other words, the physical pages of the physical units in the data area and the free area are alternatively used to map the logical pages of the logical units, to store data written by the host system. For example, the memory management circuit of a storage apparatus may get one or more physical units from the free area to be a global random unit, and when a logical access address that the host system is about to write update data into is corresponding to a logical page of a logical unit of the storage apparatus, the memory management circuit of the storage apparatus may write the update data in a physical page of the global random unit. In addition, the memory management circuit may record information indicating that the written physical page stores the update data of a logical page in a redundant bit area of the written physical pages or in an inverse mapping table, and the physical page originally mapped to the logical page will be marked as an invalid page. Accordingly, when update data of a logical page of a logical unit is stored in the global random unit, the memory management circuit must search for information from the entire inverse mapping table or the redundant bit area of the physical pages of the global random unit, and then read the valid data belonging to the logical unit. The search is very time-consuming, lowering the system effectiveness.
In particular, if the amount of available physical units in the free area is less than a predetermined threshold value, when writing commands, the memory management circuit must proceed with data merging, to avoid exhausting the physical units of the free area. Specifically, in the data merging process, the memory management circuit will get an empty physical unit from the free area, and copy valid data belonging to the same logical unit among the physical unit of the global random unit and the data area to the gotten physical block. From this, the physical units of the global random unit and the data area for storing invalid data can be erased and associated with the free area. Since the memory management circuit must perform the mentioned search during the data merging process to read all the valid data of the logical units, the data merging process performed by the memory management circuit will substantially extend the time for writing commands, even causing delay. Therefore, how to effectively manage the stored update data in the global random unit, and shorten the time required for accessing data, is one of the major subjects in the industry.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.